cmake_minimum_required(VERSION 3.10)
project(PCV LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")

if(MSVC)
  set(
    CMAKE_CXX_FLAGS
    "${CMAKE_CXX_FLAGS} /bigobj /MP /wd4005 /wd4996 /wd4819 /wd4251 /wd4267 /wd4244 /wd4275 /wd4530 /wd4334 /wd4018"
    )
  add_definitions(-D_ENABLE_EXTENDED_ALIGNED_STORAGE)
  add_compile_options("/utf-8")
endif(MSVC)

if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
  set(CMAKE_CXX_FLAGS 
    "${CMAKE_CXX_FLAGS} -Wno-write-strings -Wno-unused-result -Wno-ignored-attributes"
  )
  set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()

option(PHOTO_PROBLEM_1 "Build problem 1" OFF)

find_package(Catch2 REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(OpenCV REQUIRED)

# ceres
find_package(Ceres REQUIRED)

include_directories(${EIGEN3_INCLUDE_DIR} ${OpenCV_INCLUDE_DIRS})
if(${PHOTO_PROBLEM_1})
    file(GLOB SOURCES "problem1/*.*")
    add_executable(problem1 ${SOURCES})
    target_link_libraries(problem1 Catch2::Catch2 ceres ${OpenCV_LIBS})
endif()